#pragma once

#include <memory>
#include "common/os/file.h"
#include "common/define/noncopyable.h"

/**
 * @brief 文件操作封装类
 */
class file_helper : noncopyable
{
public:
    explicit file_helper() = default;
    ~file_helper();

public:
    using file_helper_ptr = std::shared_ptr<file_helper>;

    const filename_t& filename() const
    { return m_filename; }

public:
    void open(const filename_t &filename);

    void close();

    void write(const std::string &buffer);

    void flush();

private:
    std::FILE *m_fd{nullptr};
    filename_t m_filename;
};

#include "file_helper_inl.h"